<template>
  <div>
    <el-alert title="模板行业" type="info" show-icon>
      <div>
        IT科技/IT软件与服务<br>
        IT科技/互联网|电子商务
      </div>
    </el-alert>
    <div class="app-container ">
      <el-form ref="form" size="small" :model="form" :rules="rules" label-width="180px">
        <el-tabs v-model="activeName">

                </el-tabs>
        <el-form-item>
          <el-button size="small" type="primary" @click="submit">保存设置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  name: 'Configmessagetpl',
  components: {
  },
  data() {
    return {
      form: {
      },
      loading: false,
      activeName: '公众号模板消息配置',
      rules: {
      }
    }
  },
  mounted() {
    this.$api.post('/config/getInfo', { mo: 'messagetpl' }).then(res => {
      this.form = JSON.stringify(res.data) == '[]' ? {} : res.data
      this.setDefaultVal('keyword')
    })
  },
  methods: {
    submit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.loading = true
          this.$api.post('/config/update', this.form).then(res => {
            this.$message({ message: '操作成功', type: 'success' })
          }).catch(() => {
            this.loading = false
          })
        }
      })
    },
    setDefaultVal(key) {
      if (this.form[key] == null || this.form[key] == '') {
        this.form[key] = []
      }
    }
  }
}
</script>
